<template>
  <div class="box">
    <div class="content">
      <div class="student">
        <div class="student-avatar">
          <!-- <img
            src="https://img1.baidu.com/it/u=2716398045,2043787292&fm=253&fmt=auto&app=120&f=JPEG?w=800&h=800"
            alt=""
          /> -->
          <img v-if="tableData.studentAvatar" :src="tableData.studentAvatar" alt="" />
          <img v-else src="@/assets/images/accommodation/popup_img_peo.png" alt="" />
        </div>
        <ul class="student-info">
          <li>
            <span class="title">宿舍：</span>
            <span class="text">{{ tableData.dormitoryName }}</span>
          </li>
          <li>
            <span class="title">房间名：</span>
            <span class="text">{{ tableData.roomName }}</span>
          </li>
          <li>
            <span class="title">检查人：</span>
            <span class="text">{{ tableData.createUserName }}</span>
          </li>
          <li>
            <span class="title">检查人电话：</span>
            <span v-if="tableData.markUserPhone" class="text">{{ tableData.markUserPhone }}</span>
            <span v-else class="text">--</span>
          </li>
          <li>
            <span class="title">得/扣分：</span>
            <span :class="['text', 'red']">{{ tableData.totalMarkScore }}</span>
          </li>
          <li>
            <span class="title">评分等级：</span>
            <span class="text">{{ tableData.examineGrade }}</span>
          </li>
          <li>
            <span class="title">检查类型：</span>
            <span class="text">{{ tableData.itemSuperiorName }}</span>
          </li>
          <li>
            <span class="title">检查时间：</span>
            <span class="text">{{ tableData.examineTime }}</span>
          </li>
          <li>
            <span class="title">打分时间：</span>
            <span class="text">{{ tableData.createTime }}</span>
          </li>
        </ul>
      </div>
      <div
        v-if="
          tableData.examineType === 3 &&
          tableData.commonExamineList.length === 0 &&
          tableData.studentExamineList.length === 0
        "
        style="width: 100%; background: #f2f2f2; text-align: center; padding: 20px"
      >
        本次打分为快速打分，无打分明细，详情请联系检查人员。
      </div>
      <div v-else>
        <div class="deduct-points">
          <div v-if="tableData.commonExamineList != ''">
            <div class="small-title">公共项目打分</div>
            <div class="deduct-points-content">
              <div class="content-details">
                <ul class="porject">
                  <li v-for="(item, index) in tableData.commonExamineList" :key="index">
                    <p class="points"
                      >{{ item.markItemName }}
                      <span
                        v-if="tableData.examineType !== 1 && tableData.examineType !== 3"
                        class="deduct"
                        >：{{ item.score > 0 ? '+' + item.score : item.score }}</span
                      ></p
                    >
                  </li>
                </ul>
              </div>
              <!-- <div class="content-img-box">
              <div v-for="item in 4" :key="item" class="content-img">
                <img
                  src="https://img1.baidu.com/it/u=2716398045,2043787292&fm=253&fmt=auto&app=120&f=JPEG?w=800&h=800"
                  alt=""
                />
              </div>
            </div> -->
            </div>
          </div>
          <div v-if="tableData.studentExamineList != ''" class="deduct-points">
            <div class="small-title">个人项目打分</div>
            <div class="deduct-points-content">
              <div class="content-details">
                <ul class="personal-porject">
                  <li
                    v-for="(item, index) in tableData.studentExamineList"
                    :key="index"
                    class="personal-info"
                  >
                    <div style="margin: 0 40px 0 0; align-items: center">
                      <span style="margin: 0 16px 0 0">{{ item.studentName }}</span>
                      <span style="margin: 0 16px 0 0">{{ item.bedNum }}号床</span>
                      <span>{{ item.className }}</span>
                    </div>

                    <div>
                      <div
                        v-for="(examine, indexs) in item.examineList"
                        :key="indexs"
                        class="personal-info-li"
                      >
                        <li>
                          <span class="personal-info-content">{{ examine.markItemName }}</span>
                          <span v-if="tableData.examineType !== 1 && tableData.examineType !== 3"
                            >：{{ examine.score > 0 ? '+' + examine.score : examine.score }}</span
                          >
                        </li>
                      </div>
                    </div>
                  </li>
                </ul>
              </div>
            </div>
          </div>
          <!-- <div v-if="tableData.studentExamineList.length">
            <div class="small-title" style="margin-top: 10px">个人项目打分</div>
            <div class="deduct-points-content">
              <div class="content-details" style="max-height: 128px; overflow: auto">
                <ul v-for="(item, index) in tableData.studentExamineList" :key="index">
                  <li>
                    <span class="deduct">{{ item.studentName }}</span
                    >&nbsp; <span class="deduct"> {{ item.bedNum }}号床</span>&nbsp;
                    <span class="deduct">{{ item.className }}</span>
                    &nbsp;
                    <span class="points" style="margin-left: 20px">{{ item.markItemName }} :</span>
                    &nbsp;
                    <div
                      v-for="(examine, indexs) in item.examineList"
                      :key="indexs"
                      class="personal-info"
                    >
                      <span class="personal-info-content">{{ examine.markItemName }}</span>
                      <span class="deduct">{{
                        examine.score === 0
                          ? 0
                          : examine.score > 0
                          ? '+' + examine.score
                          : examine.score
                      }}</span>
                    </div>
                  </li>
                </ul>
              </div>
            </div>
          </div> -->
        </div>
      </div>

      <!-- 图片 -->
      <div v-if="imagess != ''" class="remarks">
        <div class="small-title">项目打分图</div>
        <div class="mark">
          <div class="content-img-box">
            <div v-for="(img, i) in imagess" :key="i" class="content-img">
              <img :src="img" alt="" />
            </div>
          </div>
        </div>
      </div>
      <!-- 备注 -->
      <div class="remarks">
        <div class="small-title">备注</div>
        <div class="mark">
          <a-textarea v-model:value="tableData.remark" readonly show-count :maxlength="140" />
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
import { onMounted, ref } from 'vue';
import { useRouter } from 'vue-router';
import { dormitoryDetails } from '@/api/assessment/dormitoryCollective';
import { message } from 'ant-design-vue';
const router = useRouter();
const schoolIdType = ref(0); // 0 是旧版本  1 是新版本
onMounted(() => {
  // if (localStorage.getItem('localStorageSchoolId') === '346001568933441537'||localStorage.getItem('localStorageSchoolId') === '221954838718582784') {
  //   schoolIdType.value = 1;
  // } else {
  //   schoolIdType.value = 0;
  // }
  let obj = {
    examineId: router.currentRoute.value.query.examineId.toString()
  };
  getTabsList(obj);
  let bodySty = document.getElementById('myApp');
  bodySty.setAttribute('class', 'bodyStyle');
});
// 信息
const tableData = ref([]);
// 图片
const imagess = ref([]);
// 获取信息
function getTabsList(obj) {
  dormitoryDetails(obj).then(res => {
    console.log(res.data.code);
    if (res.data.code === 200) {
      tableData.value = res.data.data;
      imagess.value = tableData.value.imgUrls.split(',');
    } else {
      message.error(res.data.msg);
      setTimeout(() => {
        router.go(-1);
      }, 300);
    }
  });
}
</script>

<style lang="less" scoped>
.box {
  background: #f2f2f2;
  // padding: 50px 120px 24px;
  min-height: 100vh;
  .content {
    background: #ffffff;
    border-radius: 4px;
    padding: 24px;
    .student {
      border: 1px solid #e4b778;
      border-radius: 4px;
      padding: 24px;
      width: 100%;
      display: flex;
      align-items: center;
      margin-bottom: 24px;
      .student-avatar {
        width: 80px;
        height: 106px;
        border-radius: 4px;
        overflow: hidden;
        img {
          width: 100%;
          height: 100%;
        }
      }
      .student-info {
        flex: 1;
        display: flex;
        flex-wrap: wrap;
        padding: 0 24px;
        margin-bottom: 0;
        li {
          width: 20%;
          padding: 12px 0;
          font-size: 14px;
          .title {
            color: #999999;
            display: inline-block;
            width: 40%;
            text-align: end;
          }
          .text {
            color: #222222;
          }
          .red {
            color: #ff0000;
          }
        }
      }
    }
    // .deduct-points {
    //   margin-bottom: 32px;
    //   width: 100%;
    //   &-content {
    //     padding: 14px 0 14px 16px;
    //     background: #f8f8f8;
    //     border-radius: 4px;
    //     margin-top: 20px;
    //     display: flex;
    //     align-items: center;
    //   }
    //   .content-details {
    //     width: 100%;
    //     ul {
    //       width: 33%;
    //       display: flex;
    //       justify-content: flex-start;
    //       align-items: center;
    //       flex-wrap: wrap;
    //       margin-bottom: 0;
    //       line-height: 32px;
    //       li {
    //         // width: 33%;
    //         font-size: 14px;
    //         .points {
    //           color: #999999;
    //         }
    //         .deduct {
    //           color: #222222;
    //         }
    //       }
    //     }
    //   }
    // }
    .deduct-points {
      margin-bottom: 32px;
      &-content {
        padding: 14px 16px;
        background: #f8f8f8;
        border-radius: 4px;
        margin-top: 20px;
        display: flex;
        align-items: center;
      }
      .content-details {
        width: 100%;
        .porject {
          display: flex;
          align-items: center;
          flex-wrap: wrap;
          margin-bottom: 0;
          line-height: 32px;
          li {
            width: 30%;
            font-size: 14px;
            .points {
              color: #999999;
            }
            .deduct {
              color: #222222;
            }
          }
        }
        .personal-porject {
          .personal-info {
            display: flex;
            // align-items: flex-start;
            font-size: 14px;
            font-family: Source Han Sans CN, Source Han Sans CN-Regular;
            color: #222222;
            .personal-info-li {
              display: flex;
              align-items: center;
              font-size: 14px;
              font-family: Source Han Sans CN, Source Han Sans CN-Regular;
              color: #222222;
              .personal-info-content {
                color: #999999;
              }
            }
          }
          .personal-info + .personal-info {
            margin-top: 16px;
          }
          .personal-info::before {
            content: '';
            display: inline-block;
            width: 8px;
            height: 8px;
            background: #bb964b;
            border-radius: 50%;
            margin-right: 8px;
          }
        }
      }
      .content-img-box {
        flex: 1;
        display: flex;
        align-items: center;
        justify-content: flex-start;
        flex-wrap: wrap;
        .content-img {
          width: 86px;
          height: 86px;
          border-radius: 4px;
          background: #f2f2f2;
          margin: 12px;
          overflow: hidden;
          img {
            width: 100%;
            height: 100%;
          }
        }
      }
      .mark,
      .no-found,
      .operation {
        padding: 14px 16px;
        background: #f8f8f8;
        border-radius: 4px;
        margin-top: 20px;
      }
      .no-found {
        text-align: center;
        padding: 32px;
        font-size: 16px;
        font-family: Source Han Sans CN, Source Han Sans CN-Regular;
        color: #666666;
      }
      .operation {
        &-content {
          display: flex;
          align-items: center;
          justify-content: space-between;
          font-size: 16px;
          font-family: Source Han Sans CN, Source Han Sans CN-Regular;
          color: #666666;
          margin: 8px 0;
          &-title::before {
            content: '';
            display: inline-block;
            width: 8px;
            height: 8px;
            background: #999999;
            border-radius: 50%;
            margin-right: 8px;
          }
        }
      }
    }
  }
}
.content-img-box {
  width: 50%;
  flex: 1;
  display: flex;
  // align-items: center;
  justify-content: flex-start;
  flex-wrap: wrap;
  margin-left: 10px;
  .content-img {
    width: 86px;
    height: 86px;
    border-radius: 4px;
    background: #f2f2f2;
    margin: 12px;
    overflow: hidden;
    img {
      width: 100%;
      height: 100%;
    }
  }
}
.remarks {
  width: 100%;
  margin-top: 20px;
}
.mark,
.no-found {
  padding: 14px 16px;
  background: #f8f8f8;
  border-radius: 4px;
  margin-top: 20px;
}
.no-found {
  text-align: center;
  padding: 32px;
  font-size: 16px;
  font-family: Source Han Sans CN, Source Han Sans CN-Regular;
  color: #666666;
}
.small-title {
  font-size: 18px;
  font-family: Source Han Sans CN, Source Han Sans CN-Medium;
  font-weight: 500;
  color: #222222;
}
/deep/textarea.micro-dormitory-input {
  border: 0;
  background: transparent;
  resize: none;
}
/deep/.micro-dormitory-input:focus {
  box-shadow: none;
}
// 滚动条
&::-webkit-scrollbar {
  width: 6px;
}

&::-webkit-scrollbar-thumb {
  background: rgba(20, 20, 20, 0.2);
  border-radius: 3px;
}

&::-webkit-scrollbar-track {
  background: transparent;
}

.personal-info::before {
  margin-top: 7px;
}
</style>
